home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / chapter8 / factorial.java < prev    next >
Text File  |  1995-12-31  |  278b  |  18 lines

  1. /* Recursive factorial example */
  2. class factorial {
  3.  
  4.    public static void main(String args[]) {
  5.  
  6.        System.out.println(fac(5));
  7.        }
  8.  
  9.  
  10.    public static long fac (int value) {
  11.  
  12.     if (value == 1) return 1L;
  13.  
  14.     return value * fac(value-1);
  15.  
  16.        }
  17.      }
  18.